#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Richard_Kong
"""
user_manage_api  对用户管理模块下的接口进行封装
"""
from config import config
import requests


class User_Manage_API():
    def __init__(self):

        self.headers = {
            "Content-Type": "application/json",
            'Authorization': config.Authorization
        }
        print(self.headers)

    def user_add_api(self, user_add_url,session, user_add_data):
        """

        :type session: requests.Session
        :param session:
        :return: requests.Response
        """

        response = session.post(url=user_add_url, json=user_add_data, headers=self.headers)
        return response

    def user_modify_api(self, session, user_modify_data):
        """

        :type session: requests.Session
        :param session:
        :param user_modify_data:
        :return:
        :rtype: requests.Response
        """
        user_modify_url = config.user_modify_url.format(config.user_id)
        response = session.put(url=user_modify_url, json=user_modify_data, headers=self.headers)
        return response

    def user_delete_api(self,session):
        """

        :type session: requests.Session
        :param session:
        :return: requests.Response

        url的组合应该是在接口函数中，不能放在其它位置，因为放在这里便于维护
        """

        user_delete_url = config.user_delete_url.format(config.user_id)
        response = session.delete(url=user_delete_url)
        return response

